home *** CD-ROM | disk | FTP | other *** search
- Path: ludens.elte.hu!genie
- From: genie@ludens.elte.hu
- Newsgroups: comp.sys.amiga.programmer
- Subject: Removing a patch -A POSSIBLE SOULTION
- Message-ID: <1996Jan29.141204.23597@ludens>
- Date: 29 Jan 96 14:12:04 +0200
- Organization: Eotvos University, Budapest, Hungary
-
-
- Hi to All,
-
- I got a fine reaction on my latest posting about the removing a patch problem,
- so I decided to make my possibly working version available to the public. Just
- in a nutshell, I will give an EXTREMELY SIMPLIFIED assembly code section with
- some comments in the end. (I guess you don't like reading a lot.)
- Let's see then...
-
- The code for the patch which is SetFunctioned somewhere looks like this:
-
- PatchMan: addq #1,UseCount ;how many tasks using this patch?
- tst PatchEnabled ;is it still installed?
- beq .doorig
- jsr MyPatch ;replacement for the old function
- subq #1,UseCount ;done with it
- rts
- .doorig: move.l OrigFunc,-(a7)
- rts
-
- And supposing the patch is already installed, we should remove it somehow:
-
- RemPatch: libcall Forbid ;avoid rescheduling
- tst UseCount ;still some users?
- beq .removeit
- libcall Permit ;enable rescheduling
- bsr WaitSomeTime ;let them work on
- bra RemPatch ;then try again
- .removeit: clr Enabled ;we can disable it now
- libcall Permit ;let them run
- move.l #MyPatch,a1
- libcall FreeMem ;now we can safely get rid of it
- rts
-
- That's what it is. Consider it carefully with many possible and impossible
- scheduling steps. I have tried this scheme, and it proved to work fine and
- 100% safely. Maybe it's not a brand new idea, but I haven't seen this before.
- Was I blind?
-
- Some comments:
- 1, The PatchMan routine must stay resident forever, but it really doesn't
- eat up too much space, nor consumes much time.
- 2, All the signals (UseCount, Enabled) should be stored in public semaphores.
- 3, Removing the patch can last for a while if many tasks are using the
- function. It may even freeze in a really WEIRD situation, but its
- possibility is VERY near to 0. This time could be significantly(?) reduced
- if the WaitSomeTime function sleeps for random selected times in a given
- interval.
- 4, With the use of named semaphores, many patches could be handled by
- only one resident module. It might be a good idea to implement functions
- like SetNamedPatch, IsNamedPatchInstalled, QueryNamedPatches and so in
- a shared library, so they could be easily used. Or do you think it isn't
- worth the effort and would be useless anyway? I've heard of a
- patch.library some time ago, but have never seen it. Maybe it's a similar
- solution for the problem.
-
- Good for a discussion, isn't it? Any thougths?
-
- Sorry for bothering, and sorry for my weak English as well,
-
- Genie
-
- --------------------------------------------------------------------------------
- /// Kertai 'Genie' Gabor | PGP fingerprint:
- /// from Eotvos Lorad University of Sciences | 32 36 96 9A 15 61 03 98
- \\\/// Budapest 1038, Eszak u. 39., Hungary | 7D D3 29 14 84 27 78 AC
- \XX/ E-mail: genie@ludens.elte.hu | Public key via finger...
- --------------------------------------------------------------------------------
-